// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.network.packets.hit;

import java.nio.ByteBuffer;
import zombie.characters.IsoPlayer;
import zombie.core.network.ByteBufferWriter;
import zombie.core.raknet.UdpConnection;
import zombie.inventory.types.HandWeapon;
import zombie.network.packets.INetworkPacket;

public class PlayerHitSquarePacket extends PlayerHitPacket implements INetworkPacket {
    protected final Square square = new Square();

    public PlayerHitSquarePacket() {
        super(HitCharacterPacket.HitType.PlayerHitSquare);
    }

    @Override
    public void set(IsoPlayer wielder, HandWeapon weapon, boolean isCriticalHit) {
        super.set(wielder, weapon, isCriticalHit);
        this.square.set(wielder);
    }

    @Override
    public void parse(ByteBuffer b, UdpConnection connection) {
        super.parse(b, connection);
        this.square.parse(b, connection);
    }

    @Override
    public void write(ByteBufferWriter b) {
        super.write(b);
        this.square.write(b);
    }

    @Override
    public boolean isRelevant(UdpConnection connection) {
        return this.wielder.isRelevant(connection);
    }

    @Override
    public boolean isConsistent() {
        return super.isConsistent() && this.square.isConsistent();
    }

    @Override
    public String getDescription() {
        return super.getDescription() + "\n\tSquare " + this.square.getDescription();
    }

    @Override
    protected void process() {
        this.square.process(this.wielder.getCharacter());
    }

    @Override
    public boolean validate(UdpConnection connection) {
        return true;
    }
}
